package dongshi.daddy.huohuo.eventbus.testCase;

import dongshi.daddy.huohuo.eventbus.center.EventBusCenter;
import dongshi.daddy.huohuo.eventbus.event.CustomEvent;
import dongshi.daddy.huohuo.eventbus.subscribe.Subscriber1;
import dongshi.daddy.huohuo.eventbus.subscribe.Subscriber2;
import org.junit.Test;

import java.time.Instant;

public class EventBusTestCase {

    @Test
    public void testEventBus() {
        Subscriber1 listener1 = new Subscriber1();
        Subscriber2 listener2 = new Subscriber2();
        // 定义事件
        CustomEvent customEvent = new CustomEvent(23);
        // 注册订阅者们（监听器们）
        EventBusCenter.register(listener1);
        EventBusCenter.register(listener2);
        // 发布事件
        EventBusCenter.post(customEvent);

        System.out.println(Instant.now() +",主线程执行完毕："+Thread.currentThread().getName());
    }
}
